require.config({baseUrl: '/js/lib',urlArgs: "v0.0.1"});
require(['zepto', 'lib'], function($, lib) {
  var fn = {}, lib = new lib();
  $.extend(fn, {
    timeInterVal: null,
    init: function(){
      var _t = this;
      _t.bindEvent();
    },
    bindEvent: function(){
      var _t = this;
      
      /*点击修改按钮*/
      $(document).on("tap", ".ui-red-botton:not(.ui-disable)", function(data){
        var _this = this;
        $(_this).addClass("ui-ing ui-disable");
        if(!$("input[name=oldPass]").val()){
          lib.showMessage("请输入您的原始密码");
          $(_this).removeClass("ui-ing ui-disable");
          return;
        }
        if(!$("input[name=newPass]").val() || $("input[name=newPass]").val().length < 6){
          lib.showMessage("请输入您的新密码,长度至少6位");
          $(_this).removeClass("ui-ing ui-disable");
          return;
        }
        if(!$("input[name=rePass]").val()){
          lib.showMessage("请输入再次输入新密码");
          $(_this).removeClass("ui-ing ui-disable");
          return;
        }
        if($("input[name=rePass]").val() !== $("input[name=newPass]").val()){
          lib.showMessage("请输入再次输入新密码");
          $(_this).removeClass("ui-ing ui-disable");
          return;
        }
        lib.onLoading();
        lib.ajx(lib.getReq().ser + '/user/updatePass.action', {oldPass: $("input[name=oldPass]").val(), newPass: $("input[name=newPass]").val()}, function(data){
          if(data.infocode === "0"){
            lib.showMessage("修改成功，请重新登陆");
            setTimeout(function(){
              location.href = "/seller/login.html"
            }, 1000);
          }else{
            lib.showMessage(data.info);
            $(_this).removeClass("ui-ing ui-disable");
          }
          
        }, function(){
          lib.showMessage("网络超时，请稍后再试");
          $(_this).removeClass("ui-ing ui-disable");
        });
      });
    },
    checkTel: function(num){
      var numReg = /^1[34578]\d{9}$/;
      return numReg.test(num);
    }
  });
  
  fn.init();
});